﻿
@{
    Layout = null;
}


<link href="~/libs/layui-v2.9.21/layui-v2.9.21/layui/css/layui.css" rel="stylesheet" />

<form class="layui-form" action="">
    <div class="layui-form-item">
        <label class="layui-form-label">仓库代码</label>
        <div class="layui-input-inline layui-input-wrap">
            <input type="text" id="warehouseCode" name="warehouseCode" lay-verify="required" autocomplete="off" lay-affix="clear" class="layui-input" placeholder="请输入仓库代码">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">仓库名称</label>
        <div class="layui-input-inline layui-input-wrap">
            <input type="text" id="warehouseName" name="warehouseName" lay-verify="required" autocomplete="off" lay-affix="clear" class="layui-input" placeholder="请输入仓库名称">
        </div>
    </div>
    <div class="layui-form-item">
            <label class="layui-form-label">仓库属性</label>
            <div class="layui-input-block">
                <input type="checkbox" id="warehouseAttribute1" name="warehouseAttribute" title="标准" value="标准">
                <input type="checkbox" id="warehouseAttribute2" name="warehouseAttribute" title="简易" value="简易" checked>
                <input type="checkbox" id="warehouseAttribute3" name="warehouseAttribute" title="普通" value="普通">
            </div>
        </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button type="submit" class="layui-btn" lay-submit lay-filter="add">确定</button>
            <button type="reset" class="layui-btn layui-btn-primary">关闭</button>
        </div>
    </div>
</form>

    <!-- 请勿在项目正式环境中引用该 layui.js 地址 -->
    <script src="~/libs/jquery/jquery.js"></script>
    <script src="~/libs/layui-v2.9.21/layui-v2.9.21/layui/layui.js"></script>
    <script>
        //关闭弹框
        function closeWorkStation() {
            var index = parent.layer.getFrameIndex(window.name);//先得到当前的索引
            parent.layer.close(index);//再执行关闭
        }
layui.use(['form', 'laydate', 'util'], function(){
  var form = layui.form;
  var layer = layui.layer;
  var laydate = layui.laydate;
  var util = layui.util;


  // 提交事件
  form.on('submit(add)', function(data){
      var field = data.field; // 获取表单字段值
      console.log(field)
    // 显示填写结果，仅作演示用
    layer.alert(JSON.stringify(field), {
      title: '当前填写的字段值'
    });
    // 此处可执行 Ajax 等操作
      $.ajax({
          type: 'post',
          url: '/Definition/InsertDefinition',
          dataType: 'json',
          data:field,
          success: function (res) {
              if (res > 0) {
                  layer.msg('添加成功')
                  closeWorkStation()
                  return false;
              }
              if (res == -1) {
                  layer.msg('仓库编号已存在')
                  return false;
              }
          }
      })
    return false; // 阻止默认 form 跳转
  });

 
});
    </script>

